-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement setPublicClassFields
and privateFieldsAsProperties
assumptions
#12497
Implement setPublicClassFields
and privateFieldsAsProperties
assumptions
#12497
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/37890/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2fce14d:
|
}) { | ||
const setPublicClassFields = api.assumption("setPublicClassFields"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will throw on @babel/core 7.12 + @babel/plugin-class-properties 7.13
because api
is defined but api.assumption
is not provided.
Never mind, I always forget the fact that api.assumption
has been provided by helper plugin utils.
The CI failure caught an assumption I didn't notice while writing the RFC. The class B {
method() { alert("B!"); }
}
class C {
method() { alert("C!"); }
}
class A extends B {
run() { super.method(); }
}
Object.setPrototypeOf(A.prototype, C.prototype);
new A().run(); For this reason, we compile However, in loose mode we assume that it's never mutated and thus we compile it to I'm going to add this to the RFC. |
@@ -361,13 +366,15 @@ export function transformPrivateNamesUsage( | |||
ref, | |||
path, | |||
privateNamesMap, | |||
loose, | |||
privateFieldsAsProperties, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider change the signature to { privateFieldsAsProperties: boolean }
so we can pass noDocumentAll
later. This function is not a public interface so it should be okay.
1864522
to
98ad298
Compare
dac1080
to
63e45fe
Compare
63c7a5a
to
caa4fda
Compare
63e45fe
to
2fce14d
Compare
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408) - `setClassMethods` (#12407) - `setComputedProperties` (#12490) - `ignoreFunctionLength` (#12491) - `noDocumentAll` (#12481) - `iterableIsArray` and `arrayLikeIsIterable` (#12489) - `pureGetters` (#12504) - `skipForOfIteratorClosing` (#12496) - `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505) - `noNewArrows` (#12613, #12793) - `setPublicClassFields` and `privateFieldsAsProperties` (#12497) - `constantReexports` and `enumerableModuleMeta` (#12618) - `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726) Co-authored-by: Justin Ridgewell <justin@ridgewell.name> Co-authored-by: Huáng Jùnliàng <JLHwung@users.noreply.github.com>
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408) - `setClassMethods` (#12407) - `setComputedProperties` (#12490) - `ignoreFunctionLength` (#12491) - `noDocumentAll` (#12481) - `iterableIsArray` and `arrayLikeIsIterable` (#12489) - `pureGetters` (#12504) - `skipForOfIteratorClosing` (#12496) - `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505) - `noNewArrows` (#12613, #12793) - `setPublicClassFields` and `privateFieldsAsProperties` (#12497) - `constantReexports` and `enumerableModuleMeta` (#12618) - `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726) Co-authored-by: Justin Ridgewell <justin@ridgewell.name> Co-authored-by: Huáng Jùnliàng <JLHwung@users.noreply.github.com>
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408) - `setClassMethods` (#12407) - `setComputedProperties` (#12490) - `ignoreFunctionLength` (#12491) - `noDocumentAll` (#12481) - `iterableIsArray` and `arrayLikeIsIterable` (#12489) - `pureGetters` (#12504) - `skipForOfIteratorClosing` (#12496) - `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505) - `noNewArrows` (#12613, #12793) - `setPublicClassFields` and `privateFieldsAsProperties` (#12497) - `constantReexports` and `enumerableModuleMeta` (#12618) - `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726) Co-authored-by: Justin Ridgewell <justin@ridgewell.name> Co-authored-by: Huáng Jùnliàng <JLHwung@users.noreply.github.com>
Main PR: #12219
RFC: babel/rfcs#5
I also introduced a warning when both
loose
andsetPublicClassFields
/privateFieldsAsProperties
are set (while still maintianing the fallback behavior we have for the other assumptions).This is because
loose
support for these class features plugins is a mess and easily breaks: it was what initially lead me to theassumptions
RFC. We should encourage users to fully migrate toassumptions
for these plugins when they start using them, to avoid other possible configuration conflicts caused by the implicit dependencies between them.The tests are what we already had for
loose
.